/**
 * Created by python on 19-8-24.
 */
const HOST = "http://127.0.0.1:8000/";
// 全局过滤器
// 字符串转日期对象 str2time
// 日期对象转年月日 date2ymd
// 日期对象转时分秒 date2hms
// 日期对象转星期　 date2week

Vue.filter("str_to_date", function (value) {
    return new Date(value)
});

Vue.filter("date_to_ymd", function (value) {
    var year = value.getFullYear();
    var month = value.getMonth();
    var day = value.getDate();
    return year + "-" + month + "-" + day
});

Vue.filter("date_to_md", function (value) {
    // var year = value.getFullYear();
    var month = value.getMonth();
    var day = value.getDate();
    return month + "月" + day + "日"
});

Vue.filter("date_to_hm", function (value) {
    var hour = value.getHours();
    var minute = value.getMinutes();
    return hour + ":" + minute
});

const WEEK = ["周日","周一","周二","周三","周四","周五","周六"];

Vue.filter("date_to_week", function (value) {
    var intDay = value.getDay()
    return WEEK[intDay]
});


Vue.filter("ymd_to_hans", function (value) {
    if (value == '1970-0-1') {
        value = '至今'
    }
    return value
});

Vue.filter("ymd_to_null", function (value) {
    if (value == '1970-0-1') {
        value = '暂无'
    }
    return value
});





function get_query_string(name,defValue){
            var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
            var r = window.location.search.substr(1).match(reg);
            if (r != null) {
                return decodeURI(r[2]);
            }
            return null;
        }